﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeGame.Networking.Clientside.ServerClientPackets
{
    class ChangeTokenPacket : ClientPacket
    {
        private string Token;

        public override ServerClientNet GetID()
        {
            return ServerClientNet.ChangeToken;
        }

        public override bool Validate(Lidgren.Network.NetIncomingMessage msg)
        {
            this.Token = msg.ReadString();
            if (!this.ValidateString(this.Token))
            {
                return false;
            }
            return true;
        }

        public override void Handle()
        {
            Singletons.Network.SetToken(this.Token);
        }

        public override void Handle(Lidgren.Network.NetIncomingMessage message)
        {
            this.Validate(message);
            this.Handle();
        }
    }
}
